added Feb 2001 SDK
[windows-sources.git] / shared source / vb / language / shared / ccomptrex.h
blobd7290dc29668df65a59c5a88fd07129bd27d030c
1 //-------------------------------------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // Wrapper for CComPtrEx which can handle inheritance scenarios where there are multiple paths
6 // to IUnknown
7 //
8 //-------------------------------------------------------------------------------------------------
10 #pragma once
12 template <class T>
13 class CComPtrEx : public CComPtrBase<T>
15 public:
16 CComPtrEx() throw()
19 CComPtrEx(T* lp) throw() :
20 CComPtrBase<T>(lp)
24 CComPtrEx(_In_ const CComPtrEx<T>& lp) throw() :
25 CComPtrBase<T>(lp.p)
28 T* operator=(_In_opt_ T* lp) throw()
30 if(*this!=lp)
32 CComPtrEx<T> sp(lp);
33 TemplateUtil::Swap(&p, &sp.p);
35 return *this;
37 T* operator=(_In_ const CComPtrEx<T>& lp) throw()
39 if(*this!=lp)
41 CComPtrEx<T> sp(lp);
42 TemplateUtil::Swap(&p, &sp.p);
44 return *this;